import Variable from "../constants/index";

Page({
  data: {
    avatarUrl: 'https://game.gtimg.cn/images/lol/act/a20241008superfan/bg_01.jpg', // 头像地址
    userName: '王*颜',
    userAddress: '月亮湾小区服务站',
    onlineTime: '您已累计在线 60 小时',
    walletAmount: 300,
    orderCount: 4
  },
  touserinfo(){
    wx.navigateTo({
      url:'/pages/userinfo/userinfo'
    })
  },

  //更换头像
async changeAvatar(){
   //弹出相册/拍照选择器
   const result =await wx.chooseMedia({
      count:1,
      mediaType:["image"]
    })
    if (result.tempFiles.length) {
      this.setData({
        avatarUrl:result.tempFiles[0].tempFilePath
      })
    }
   },

  goToWallet: function () {
    wx.navigateTo({
      url: '/pages/wallet/wallet'
    });
  },
  goToOrderStats: function () {
    wx.navigateTo({
      url: '/pages/orderStats/orderStats'
    });
  },
  goToMyEvaluation: function () {
    wx.navigateTo({
      url: '/pages/myEvaluation/myEvaluation'
    });
  },
  goToMyTransport: function () {
    wx.navigateTo({
      url: '/pages/myTransport/myTransport'
    });
  },
  goToMyChild: function () {
    wx.navigateTo({
      url: '/pages/myChild/myChild'
    });
  },
  goToRequestHelp: function () {
    wx.navigateTo({
      url: '/pages/requestHelp/requestHelp'
    });
  },
  goToHelpAndCs: function () {
    wx.navigateTo({
      url: '/pages/helpAndCs/helpAndCs'
    });
  },
  // 只要页面展示就执行
  onShow(){
    // 有资料 在本地存储 
    const nickname = wx.getStorageSync(Variable.NICKNAME_KEY)
    const avatar = wx.getStorageSync(Variable.AVATAR_KEY)
    this.setData({
      avatarUrl: avatar,
      userName: nickname
    })
  }
});